#include<iostream>
using std::cout; using std::endl; using std::ostream;
class Rational{
    public:
        Rational(int numerator = 0, int denominator = 1);
        const Rational operator*(const Rational &rhs) const;
    private:
        int n,d;
    friend ostream& operator<<(ostream &os,const Rational &lhs);
};

Rational::Rational(int numerator,int denominator):n(numerator),d(denominator){

}

ostream& operator<<(ostream &os,const Rational &lhs){
    os << lhs.n << "/" << lhs.d;
}

const Rational Rational::operator*(const Rational &rhs) const{ 
    return Rational(this->n * rhs.n, this->d * rhs.d);;
}



int main(){
    Rational a(1,2);
    Rational b(3,5);

    Rational c = a * 2; // correct
    Rational d = 2 * b; // Error!
    cout << c << d << endl;
}